#!/bin/bash
Route=$(route -n|grep "^0.0.0.0"|awk '{print $2}')
Hwaddr=$(/sbin/ifconfig eth0|grep -i HWaddr|awk '{print $5}')
Ipaddr=$(/sbin/ifconfig eth0 |grep "inet addr:" |awk -F "[ :]+" '{print $4}')
Netmask=$(/sbin/ifconfig eth0|awk -F: 'NR==2{print $NF}')
DNS1=202.96.134.33
DNS2=202.96.128.86

cat >/etc/sysconfig/network-scripts/ifcfg-eth0 <<EOF
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
HWADDR=$Hwaddr
IPADDR=$Ipaddr
NETMASK=$Netmask
GATEWAY=$Route
DNS1=$DNS1
DNS1=$DNS2
EOF